/**
 * @file PasteSurfaceCommand.cpp
 *
 * @date 26/12/2011
 * @author Tales 
 *
 */

#include "PasteSurfaceCommand.hpp"
#include "PictureState.hpp"
#include "../Graphics.hpp"

namespace yep
{

PasteSurfaceCommand::PasteSurfaceCommand(SDL_Surface *src, const pair<int, int> &pos, const Color &color, int layer) :
		Command(color, layer), position(pos)
{
	this->src = src;
}

PasteSurfaceCommand::~PasteSurfaceCommand()
{
	SDL_FreeSurface(src);
}

void PasteSurfaceCommand::execute(PictureState & state)
{
	Graphics g(state.getLayer(getLayerIndex()).getSurface());
	g.blit(src, position);
}

} /* namespace yep */
